﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using DTO;

namespace DAO
{
    public class ChiTietHoaDonDAO : AbtractDAO
    {
        public static void themChiTietHoaDon (long mahoadon,long machitietphieuthue)
        {
            OleDbConnection ketNoi = null;
            try
            {
                ketNoi = KetNoi();
                string chuoiLenh = "INSERT INTO CHITIETHOADON(MaHoaDon,MaChiTietPhieuThue) VALUES(@MaHoaDon,@MaChiTietPhieuThue)";

                OleDbCommand lenh = new OleDbCommand(chuoiLenh, ketNoi);

                OleDbParameter thamSo;

                thamSo = new OleDbParameter("@MaHoaDon", OleDbType.Integer);
                thamSo.Value = mahoadon;
                lenh.Parameters.Add(thamSo);

                thamSo = new OleDbParameter("@MaChiTietPhieuThue", OleDbType.Integer);
                thamSo.Value = machitietphieuthue;
                lenh.Parameters.Add(thamSo);

                lenh.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (ketNoi != null && ketNoi.State == System.Data.ConnectionState.Open)
                    ketNoi.Close();
            }
        }
     
    }
}
